package com.yeyks.app.controller.base.config;


import cn.hutool.core.util.StrUtil;
import com.yeyks.app.annotation.UnUpdateCheck;
import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.common.exception.ServiceException;
import com.yeyks.config.pojo.param.WebConfigurationSystemVersionParam;
import com.yeyks.config.service.WebConfigurationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author yun
 * @since 2019-11-27
 */
@Api(tags = "配置")
@Slf4j
@RestController
@RequestMapping("/app/webConfiguration")
@Validated
public class WebConfigurationController {

    @Autowired
    private WebConfigurationService webConfigurationService;

    /**
     * 获取版本信息
     *
     * @return
     */
    @ApiOperation(value = "获取web动态配置内容:v3.8")
    @RequestMapping(value = "/get", method = RequestMethod.POST)
    @UnUpdateCheck
    public AjaxResponseBody<String> systemVersion(WebConfigurationSystemVersionParam param) {
        String value = webConfigurationService.getValue(param);
        if (StrUtil.isBlank(value)) {
            throw new ServiceException("配置不存在");
        }
        return AjaxResponseBody.success(value);
    }

}
